<?php
//新闻表的model
include DOCMENT_ROOT.'/Framework/model.class.php';
class newModel extends model{
   public function __construct(){
       parent::connectMysqlDB("school");
    }
    //查询
    public function newselect($id){
       $sql="select * from new where id=$id";
        $arr = $this->mysql->select($sql);
        return $arr;
    }
    public function newList($order="id asc",$num=5,$start=0){
        $sql = "select * from new order by $order limit $start,$num";//拼接sql语句
        $arr = $this->mysql->select($sql);//查询
        return $arr;//返回结果
    }
    public function newCount(){
        $sql="select count(*) as num from new";   //查询总条数
        $arr = $this->mysql->select($sql);
        $count = 0;
        if(!empty($arr)) {
            $count = $arr[0]["num"];
        }
        return $count;
    }
    //验证内容重复
      public function checkContent($where){
        $sql="select * from new where $where";
        $result = $this->mysql->select($sql);
        if($result==null){
            return true;
        }else{
            return false;
        }
    }
    //删除
     public function deleteOne($id){
       $sql="delete from new where id=$id";
       $result = $this->mysql->delete($sql);
       return $result;
    }
    //修改
    public function updateOne($title,$content,$id){
        $sql="update new set title = '$title',content='$content' where id= $id";
        $arr = $this->mysql->update($sql);
        return $arr;
    }
    
}
